package cn.stylefeng.guns.modular.business.controller;

import cn.stylefeng.guns.modular.business.pojo.RiverDevelopmentRequest;
import cn.stylefeng.guns.modular.business.service.RiverDevelopmentService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 河道历史沿革控制器
 *
 * @author zhangyaowen
 * @date 2021/10/08 16:51
 */
@RestController
@ApiResource(name = "河道历史沿革")
public class RiverDevelopmentController {

    @Resource
    private RiverDevelopmentService riverDevelopmentService;

    /**
     * 添加
     *
     * @author zhangyaowen
     * @date 2021/10/08 16:51
     */
    @PostResource(name = "添加", path = "/riverDevelopment/add")
    public ResponseData add(@RequestBody @Validated(RiverDevelopmentRequest.add.class) RiverDevelopmentRequest riverDevelopmentRequest) {
        riverDevelopmentService.add(riverDevelopmentRequest);
        return new SuccessResponseData();
    }

    /**
     * 删除
     *
     * @author zhangyaowen
     * @date 2021/10/08 16:51
     */
    @PostResource(name = "删除", path = "/riverDevelopment/delete")
    public ResponseData delete(@RequestBody @Validated(RiverDevelopmentRequest.delete.class) RiverDevelopmentRequest riverDevelopmentRequest) {
        riverDevelopmentService.del(riverDevelopmentRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑
     *
     * @author zhangyaowen
     * @date 2021/10/08 16:51
     */
    @PostResource(name = "编辑", path = "/riverDevelopment/edit")
    public ResponseData edit(@RequestBody @Validated(RiverDevelopmentRequest.edit.class) RiverDevelopmentRequest riverDevelopmentRequest) {
        riverDevelopmentService.edit(riverDevelopmentRequest);
        return new SuccessResponseData();
    }

    /**
     * 查看详情
     *
     * @author zhangyaowen
     * @date 2021/10/08 16:51
     */
    @GetResource(name = "查看详情", path = "/riverDevelopment/detail")
    public ResponseData detail(@Validated(RiverDevelopmentRequest.detail.class) RiverDevelopmentRequest riverDevelopmentRequest) {
        return new SuccessResponseData(riverDevelopmentService.detail(riverDevelopmentRequest));
    }

    /**
     * 获取列表
     *
     * @author zhangyaowen
     * @date 2021/10/08 16:51
     */
    @GetResource(name = "获取列表", path = "/riverDevelopment/list")
    public ResponseData list(RiverDevelopmentRequest riverDevelopmentRequest) {
        return new SuccessResponseData(riverDevelopmentService.findList(riverDevelopmentRequest));
    }

    /**
     * 获取列表（带分页）
     *
     * @author zhangyaowen
     * @date 2021/10/08 16:51
     */
    @GetResource(name = "分页查询河道历史沿革", path = "/riverDevelopment/page")
    public ResponseData page(String name) {
        RiverDevelopmentRequest riverDevelopmentRequest = new RiverDevelopmentRequest();
        riverDevelopmentRequest.setRhdRiver(name);
        return new SuccessResponseData(riverDevelopmentService.findPage(riverDevelopmentRequest));
    }

    /**
     * 获取河道历史沿革详情
     *
     * @param id
     * @return
     */
    @GetResource(name = "河道历史沿革详情", path = "/riverDevelopment/toReview")
    public ResponseData toReview(String id) {

        return new SuccessResponseData(riverDevelopmentService.toReview(id));
    }


}